package com.tanhua.dubbo.db.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dubbo.db.mappers.QuestionMapper;
import com.tanhua.model.db.Question;
import com.tanhua.model.db.Settings;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class QuestionApiImpl implements QuestionApi {

    @Autowired
    private QuestionMapper questionMapper;

    //根据userId查询
    @Override
    public Question findByUserId(Long userId) {

        QueryWrapper<Question> qw=new QueryWrapper<>();
        qw.eq("user_id",userId);
        Question question = questionMapper.selectOne(qw);
        return question;
    }

    //保存陌生人问题
    @Override
    public void saveQuestion(Question question) {

        questionMapper.insert(question);
    }

    //更新陌生人问题
    @Override
    public void updateQuestion(Question question) {
        questionMapper.updateById(question);

    }
}
